var DEFAULT_TMALL_BANNER = [
  {
    image_zh: `${CDN_PREFIX}/images/pages/tmall-2020-06-29-zh.jpg`,
    image_en: `${CDN_PREFIX}/images/pages/tmall-2020-06-29-en.jpg`,
    extra: {
      h5Url: 'https://starbucks.m.tmall.com/',
      pcUrl: 'https://starbucks.tmall.com/'
    }
  }
];
var BANNER_CACHE_TMALL = 'BANNER_CACHE_TMALL';

function handleTmallBannerRes(result) {
  if(result && result.length > 0) {
    let image = '';
    let h5Url = '';
    let pcUrl = '';
    var tmallBanner = result[0];
    // 图、链接
    image = LOCALE === 'zh' ? tmallBanner.image_zh : tmallBanner.image_en;
    h5Url =  tmallBanner.extra.h5Url;
    pcUrl =  tmallBanner.extra.pcUrl;
    $('#home-left-campaign-img').attr('src',`${image}`); 
    $("#home-left-campaign").click(function() {
      if(window.innerWidth >= 800) {
        $('#home-left-campaign').attr('href',`${pcUrl}`); 
      } else {
        $('#home-left-campaign').attr('href',`${h5Url}`); 
      }
    });
    return;
  }
}

function setTmallBanner() {
  getBannerConfig('tmall-banner', BANNER_CACHE_TMALL, DEFAULT_TMALL_BANNER, handleTmallBannerRes);
}

setTmallBanner();
